<template>
  <div class="top-container">
    <div class="left-box">
      <div class="icon-wrapper">
        <span class="iconfont icon-home" @click="toHome()"></span>
        <span class="iconfont icon-sami-select"></span>
        <span class="iconfont icon-full-screen"></span>
      </div>
      <div class="history-wrapper">
        <span class="iconfont icon-arrow-left" @click="() => {this.$router.go(-1)}"></span>
        <span class="iconfont icon-arrow-right" @click="() => {this.$router.go(1)}"></span>
      </div>
    </div>
    <div class="right-box">
      <div class="el-input el-input--small el-input--prefix">
        <input
          type="text"
          autocomplete="off"
          placeholder="搜索"
          class="el-input__inner"
          v-model="inputValue"
          @keyup.enter="toResult"
        />
        <span class="el-input__prefix">
          <i class="el-input__icon el-icon-search"></i>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'top',
    data() {
      return {
        inputValue: ''
      }
    },
    methods:{
      toResult(){
        if(this.inputValue.trim()==''){
          this.$message.warning('输入内容不能为空！')
        }else{
          this.$router.push('./result?q='+this.inputValue);
        }
      },
      toHome(){
        this.$router.push('/discovery');
      }
    }
  }
</script>

<style scoped>
.left-box {
  padding-top: 10px;
}
</style>
